fs: accept all valid utf8 values in fast paths - #64341
hamidrezaghavami wants to merge 1 commit into
Conversation
bfaade2 to
1d3f916
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64341 +/- ##
==========================================
+ Coverage 90.35% 90.36% +0.01%
==========================================
Files 792 792
Lines 275500 275506 +6
Branches 52791 52797 +6
==========================================
+ Hits 248932 248971 +39
+ Misses 16992 16945 -47
- Partials 9576 9590 +14
🚀 New features to boost your workflow:
|
|
I don't think we should land this. The more checks we have, the more performance impact it would create. Do you have any examples out there that is impacted by this? Does people really pass UTF8? If not, let's close this. |
|
Hi @anonrig thanks for the review! I completely understand the concern regarding the performance impact on the fast path. I picked this up to resolve issue #49888, as there seemed to be some inconsistency in how variations like That said, if the consensus is that the branch/check overhead for the 99% of users passing standard |
1d3f916 to
fccaa91
Compare
|
The commit message linting and sign-off trailer are fixed, and all CI checks are passing! Could someone from the @nodejs/fs team please take a look when you have a moment? Thanks! |
Use normalizeEncoding so readFileSync/writeFileSync take the C++ fast path for UTF8, UTF-8, and mixed-case variants, not only lowercase utf8/utf-8. Refs: nodejs#64341
|
It looks like this commit is cherry-picked in #64396 |
|
Hey @trivikr! Since #64396 is currently blocked by conflicts and Windows CI failures, would it make sense to go ahead and merge this one first, since it already has approvals and green tests? That way, this UTF-8 logic is safely secured in main, and the other PR can just naturally rebase over it when it is ready. Let me know what you think! |
|
I think this should land. WDYT @anonrig? |
|
@trivikr Friendly ping on this! Since you mentioned this should land, and all 30 checks are green, could we move forward with merging it, or should we tag someone else since anonrig seems busy? I defer to your judgment as a core maintainer on the next steps. |
|
Hi @jasnell @gurgunday — gentle ping on this when you have a moment. Changes are approved and ready for CI. Thanks! |
55bbc5a to
221cbd5
Compare
Signed-off-by: Hamid Reza Ghavami <hamidr.ghavami@gmail.com>
221cbd5 to
242013b
Compare
|
@jasnell @gurgunday The merge conflicts are fully resolved, and the JS is clean. Could you take a look at re-approving and triggering a fresh Jenkins CI run when you have a moment? Thanks! |
Fixes: #49888
This PR introduces a lightweight
isUtf8Encodinghelper to ensurefs.readFileSync,fs.writeFileSync, andencodeRealpathResultuse the fast C++ path for all valid variations of the utf8 encoding string (utf8,utf-8,UTF8,UTF-8).